package com.doraemon.mapper;

import com.github.pagehelper.Page;
import com.doraemon.annotation.AutoFill;
import com.doraemon.dto.EmployeePageQueryDTO;
import com.doraemon.entity.Employee;
import com.doraemon.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 员工管理Mapper
 */
@Mapper
public interface EmployeeMapper {

    /***
     * 根据 员工用户名 查询员工
     * ---
     * @param username 员工用户名
     * @return: com.doraemon.entity.Employee 员工实体
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /***
     * 插入 员工 数据
     * 由-AOP处理-
     * ---
     * @param employee 员工实体
     * @return: void
     */
    @Insert("insert into employee (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Employee employee);

    /***
     * 根据 员工分页DTO类 分页查询员工
     * ---
     * @param employeePageQueryDTO 员工分页DTO类
     * @return: com.github.pagehelper.Page<com.doraemon.entity.Employee>
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /***
     * 根据 员工实体 更新员工
     * -由AOP处理-
     * ---
     * @param employee 员工实体
     * @return: void
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Employee employee);

    /***
     * 根据 员工id 查询员工
     * ---
     * @param id 员工id
     * @return: com.doraemon.entity.Employee 员工实体
     */
    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);
}
